<?php

class JSONFileCacher
{

	private $folder;

	public function __construct($config)
	{
		$this->folder = $config["folder"];
	}

	public function recover_record($id_record_cache)
	{
		$filename = $this->folder."/".$id_record_cache;
		if (file_exists($filename))
		{
			return json_decode(file_get_contents($filename));
		}
		
		return null;
	}

	public function cache_record($id_record_cache, $record_info)
	{
		$filename = $this->folder."/".$id_record_cache;
		return file_put_contents($filename, json_encode($record_info));
	}
	
}